import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
import _Portal from "@mui/material/Portal";
import _useMediaQuery from "@mui/material/useMediaQuery";
import classNames from "classnames";
import React, { useMemo, useRef } from "react";
import styles from "./index.module.less";
import { useEventListener } from "ahooks";
import { walletRootRef } from "../../utils";
import { jsx as _jsx } from "react/jsx-runtime";
var Overlay = function(props) {
    var dom = useRef(null);
    var lockScroll = props.lockScroll, zIndex = props.zIndex, customStyle = props.customStyle, duration = props.duration, show = props.show, className = props.className, propsStyle = props.style, _props_fullScreen = props.fullScreen, fullScreen = _props_fullScreen === void 0 ? true : _props_fullScreen, container = props.container, reset = _object_without_properties(props, [
        "lockScroll",
        "zIndex",
        "customStyle",
        "duration",
        "show",
        "className",
        "style",
        "fullScreen",
        "container"
    ]);
    var isPc = _useMediaQuery("(min-width:1280px)");
    var onTouchMove = function(event) {
        if (props.lockScroll) {
            if (typeof (event === null || event === void 0 ? void 0 : event.cancelable) !== "boolean" || event.cancelable) {
                event.preventDefault();
            }
            event.stopPropagation();
        }
    };
    useEventListener("touchmove", onTouchMove, {
        target: dom
    });
    var style = useMemo(function() {
        return _object_spread_props(_object_spread(_object_spread_props(_object_spread({}, propsStyle), {
            zIndex: props.zIndex
        }), props.customStyle), {
            animationDuration: "".concat(props.duration, "s")
        });
    }, [
        props.zIndex,
        props.customStyle,
        props.duration,
        propsStyle
    ]);
    var children = /*#__PURE__*/ _jsx("div", _object_spread_props(_object_spread({
        ref: dom,
        className: classNames(props.className, styles.overlay, fullScreen ? styles.overlay_fullScreen : styles.overlay_local, props.show ? styles.show : styles.hide),
        style: style
    }, reset), {
        children: props.children
    }));
    /** 当传入容器时 强制渲染进容器内 */ return !props.fullScreen && isPc || !!container ? /*#__PURE__*/ _jsx(_Portal, {
        container: container !== null && container !== void 0 ? container : walletRootRef.current,
        children: children
    }) : children;
};
export default Overlay;

 //# sourceMappingURL=index.js.map